﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;
using BobcatUtility;
using System.Runtime.Serialization;

namespace CNShapes
{
    /// <summary>
    /// This shape stores freehand drawings. This is just a collection of points
    /// that should be rendered with lines between them.
    /// </summary><remarks>
    /// Note on addPoint
    /// ----------------
    /// To add a point to the shape you should always call the addPoint(point) method.
    /// You should not add points using Points.Add(point). This is because we may need 
    /// to update the  shape's bounds and raise events when points are added, so it 
    /// must be done through a method that we have control over.
    /// </remarks>
    [DataContract]
    public class Shape_Freehand : ShapeBase_DrawnWithPen
    {
        #region Public properties

        /// <summary>
        /// Collection of points that make up this shape.
        /// </summary>
        public IList<PointF> Line
        {
            get { return m_Line; }
        }

        #endregion

        #region Public methods

        /// <summary>
        /// Adds a point to the drawing.
        /// </summary>
        public void addPoint(PointF point)
        {
            // We add the point to the current line and update the bounds if necessary...
            m_Line.Add(point);
            updateBounds(point);

            // We raise an event to say that the shape has changed...
            raiseShapeEditedEvent();
        }

        #endregion

        #region Private data

        // The current line, and the collection of lines that make up the shape...
        [DataMember]
        private IList<PointF> m_Line = new List<PointF>();

        #endregion
    }
}
